<?php
defined('_JEXEC') or die('Restricted access'); 
$row = $this->row;

//$old_image =$row->image;


JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'description' );
$cparams = JComponentHelper::getParams ('com_media');

?>
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform( pressbutton );
		return;
	}
	if (pressbutton == 'save' || pressbutton == 'apply') {
		
		if ( form.title.value == "" ) {
			alert("<?php echo JText::_( 'Credit package must have name', true ); ?>");
			form.title.focus();
			return;
		}
		
		var cost =form.price.value;
		var numericExpression = /^[0-9]+$/;
		var numericExpression1 = /^[0-9]+\.[0-9]{1,2}$/;
		$submitform = 0;
		if ((cost == ""))
		{
			alert("<?php echo JText::_( 'Credit price could not be empty', true ); ?>");
			form.price.focus();
			return;
		}
		else 
		{
			if(cost !="")
			{
				if(cost.match(numericExpression)||cost.match(numericExpression1))
				{
					$submitform =1;
				}
				else
				{
					alert("<?php echo JText::_( 'Credit price must be numeric', true ); ?>");
					form.price.focus();
					return;
				}
			}
			
		}
		credit_value = form.value.value;
		if ((credit_value == ""))
		{
			alert("<?php echo JText::_( 'Credit number could not be empty', true ); ?>");
			form.value.focus();
			return;
		}
		else 
		{
			if(credit_value !="")
			{
				if(credit_value.match(numericExpression)||credit_value.match(numericExpression1))
				{
					$submitform =1;
				}
				else
				{
					alert("<?php echo JText::_( 'Credit number must be numeric', true ); ?>");
					form.value.focus();
					return;
				}
			}
			
		}
		if($submitform ==1)
		{
			submitform(pressbutton);
			return;
		}
	}
	else {		
		submitform(pressbutton);
	}
}
function RemoveImage(filename,type,controller,id){
	$('showimg').innerHTML = "";
	$('remove_img').value = 1;
}
</script>
	
<form name="adminForm" action="index.php" method="post" enctype="multipart/form-data">

	<table width="100%">
	<tr>
	
		<td width="80%" valign="top" align="left">
		
		    <div style="width:100%;">
				<fieldset class="adminform">
					<legend><?php echo JText::_( 'Credit detail' ); ?></legend>
						<table class="admintable">
						<tr>
							<td class="key">
								<label for="title" width="100">
									<?php echo JText::_( 'Name' ); ?>:					
								</label>
								<br />
								<small>
									<?php echo JText::_('Will be displayed to user');?>
								</small>
							</td>
							<td colspan="2">
								<input class="text_area" type="text" name="title" id="title" value="<?php echo $row->title; ?>" size="50" maxlength="50" title="<?php echo JText::_( 'A long name to be displayed in headings' ); ?>" />
								<font color="Red">*</font>
							</td>
						</tr>
						<tr>
							<td valign="top" class="key">
								<label for="access">
									<?php echo JText::_( ' Credit' ); ?>:	
								</label>
								<br />
								<small><?php echo JText::_('Please enter number of credit');?></small>
							</td>
							<td>
								<input type="text" value="<?php echo $row->value; ?>" name="value" id="value"/>	
								<font color="Red">*</font>
							</td>
						</tr>
						<tr>
							<td class="key">
								<label for="image">
									<?php echo JText::_( 'Price' ); ?>:	
								</label>
								<br/>
								<small><?php echo JText::_('Enter only digits (and period, if necessary).');?><small>
							</td>
							<td>
								<?php if($this->config['payment']->get('ordercurrency', 1)){?>
									<?php echo $this->config['payment']->get('currency', '$');?> <input class="text_area" type="text" name="price" id="price" value="<?php echo $row->price; ?>" size="50" maxlength="100"  />	
								<?php }else{?>
									<input class="text_area" type="text" name="price" id="price" value="<?php echo $row->price; ?>"  size="50" maxlength="100"  />	
									<?php echo $this->config['payment']->get('currency', '$');?> 
								<?php }?>  
								<font color="Red">*</font>
							</td>
						</tr>	
						<tr>
							<td width="120" class="key">
								<?php echo JText::_( 'Enable TAX' ); ?>:						</td>
							<td>
								<?php
								$enable_tax = ($row->id) ? $row->enable_tax : 1;								
								$lists['enable_tax'] = JHTML::_('select.booleanlist',  'enable_tax', 'class="inputbox"', $enable_tax );
								echo $lists['enable_tax']; ?>						
							</td>
						</tr>					
						<tr>
							<td width="120" class="key">
								<?php echo JText::_( 'Published' ); ?>:						</td>
							<td>
								<?php
								$published = ($row->id) ? $row->published : 1;
								$lists['published'] = JHTML::_('select.booleanlist',  'published', 'class="inputbox"', $published );
								 echo $lists['published']; ?>						
							</td>
						</tr>
						
					</table>
				</fieldset>
				<br />
				
			</div>
		</td>
	</tr>
	</table>
	<div class="clr"></div>
	<input type="hidden" name="image_old" value="<?php echo $old_image?>">
	<input type="hidden" name="option" value="<?php echo $this->option; ?>" />
	<input type="hidden" name="view" value="jacredits" />
	<input type="hidden" name="oldname" value="<?php echo $row->name ; ?>" />
	<input type="hidden" name="id" value="<?php echo $row->id; ?>" />
	<input type="hidden" name="task" value="" />
	<?php echo JHTML::_( 'form.token' ); ?>	
</form>
<style type="text/css">
	table.admintable td.key{
		width:250px;
	}								
</style>